#!/bin/sh
# Print additional version information for non-release trees.

usage() {
	echo "Usage: $0 <baseversion> [srctree]" >&2
	exit 1
}

baseversion=$1
[ -n "$baseversion" ] || usage

cd "${2:-.}" || usage

version=$baseversion

# Check for git and a git repo.
if head=`git rev-parse --verify HEAD 2>/dev/null`; then

        if descr=`git describe --tags --dirty 2>/dev/null` ; then
                descr=${descr#v}
                printf '%s' "$descr"
                exit 0
        fi

else
        printf "$baseversion"
fi

